﻿using OASystem.BLL.IService;
using OASystem.BLL.Service;
using OASystem.Model;
using OASystem.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

namespace OASystem.Controllers
{
    public class MailListController : Controller
    {
        private MailListService _mailListService = new MailListService();
        private MailList_tailService mailListService = new MailList_tailService();
        public static Maillist maillist;

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public JsonResult MaiPageList(int page, int limit, string username, string departid)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult = _mailListService.MaiPageList(page, limit, username, Convert.ToInt32(departid));
            return Json(responseResult, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 添加通讯录
        /// </summary>
        /// <param name="maillist"></param>
        /// <returns></returns>
        public JsonResult MailAdd(Maillist maillist)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.data = mailListService.MailAdd(maillist);
            return Json(responseResult);
        }
        /// <summary>
        /// 删除通讯录
        /// </summary>
        /// <param name="maillist"></param>
        /// <returns></returns>
        public JsonResult MailDel(Maillist maillist)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.data = _mailListService.MailDel(maillist);
            return Json(responseResult);
        }
        /// <summary>
        /// 显示编辑的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult Update(int id)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult = _mailListService.Update(id);
            maillist = responseResult.data as Maillist;
            return Json(responseResult);
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="maillist"></param>
        /// <returns></returns>
        public JsonResult MailUpdate(Maillist maillist)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.data = _mailListService.MailUpdate(maillist);
            return Json(responseResult);
        }
        /// <summary>
        /// 通讯录表的批量删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult MoreDel(string id)
        {
            ResponseResult result = new ResponseResult();
            result = _mailListService.MoreDel(id);
            return Json(result);
        }
        /// <summary>
        /// 判断
        /// </summary>
        /// <param name="maillist"></param>
        /// <returns></returns>
        public JsonResult QueryMail(string name)
        {
            //操作对象
            ResponseResult result = new ResponseResult();
            result.data = mailListService.QueryMail(name);
            return Json(result.data);
        }
    }
}